package com.project.comom;

import org.springframework.util.StringUtils;


public class DateDealUtils {


    public static String castInputDateStrToRequireFormat(String input) {
        if (!StringUtils.hasText(input)) return "";
        input = input.trim();
        if (input.matches("^\\d{4}$")) {
            return input + "-01-01 00:00:00";
        } else if (input.matches("^\\d{4}-\\d{2}$")) {
            return input + "-01 00:00:00";
        } else if (input.matches("^\\d{4}-\\d{2}-\\d{2}$")) {
            return input + " 00:00:00";
        } else if (input.matches("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$")) {
            return input;
        }
        return null;
    }
}
